package com.itheima.leadnews.search.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.itheima.leadnews.search.service.ApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/v1/history")
public class ApUserSearchController {

    @Autowired
    private ApUserSearchService apUserSearchService;

    /**
     * 展示搜索历史
     */
    @PostMapping("/load")
    public ResponseResult load(@RequestBody Map<String,Integer> dto){
        Integer pageSize = dto.get("pageSize");
        return apUserSearchService.load(pageSize);
    }

    /**
     * 删除搜索历史
     */
    @PostMapping("/del")
    public ResponseResult del(@RequestBody Map<String,String> map){
        String id = map.get("id");
        return apUserSearchService.del(id);
    }

}
